package com.example.domain;

public class GirlFriend {
    private String name;
    private Integer age;

    public GirlFriend() {
    }

    public GirlFriend(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    /**
     * 获取
     *
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     *
     * @param name
     */
    public void setName(String name) {
        if (name.length() <= 3) this.name = name;
        else {
            throw new NameFormatException(name + "名字格式有误,重新输入: ");
        }
    }

    /**
     * 获取
     *
     * @return age
     */
    public Integer getAge() {
        return age;
    }

    /**
     * 设置
     *
     * @param age
     */
    public void setAge(Integer age) {
        if (age <= 24 && age >= 18) this.age = age;
        else {
            throw new AgeOutOfBoundsException(age + "年龄格式有误,重新输入: ");
        }
    }

    public String toString() {
        return "GirlFriend{name = " + name + ", age = " + age + "}";
    }
}
